<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    $wechat = app('wechat');
    $qrcode = $wechat->qrcode;
    $result = $qrcode->temporary(56,3600);
    //return $result;
    return view('welcome',compact('result','qrcode'));
});

Route::group(['middleware'=>['web']],function (){
    Route::get('/users','UsersController@users');
    Route::get('/user/{openId}','UsersController@user');
    Route::get('/remark','UsersController@remark');
    Route::get('/image','MaterialController@image');//上传图片
    Route::get('/audio','MaterialController@audio');//上传音频文件
    Route::get('/materials','MaterialController@materials');//获取所有图片的信息
    Route::get('/materials/{mediaId}','MaterialController@media');
    Route::get('/message','MaterialController@message');
    Route::get('/text','MaterialController@text');
    Route::get('/menu','MenuController@menu');
    Route::get('/menu/all','MenuController@all');
});

Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
    Route::get('/user', function () {
        $user = session('wechat.oauth_user'); // 拿到授权用户资料

        //dd($user);
        return view('user',compact('user'));
    });
});
Route::any('/wechat', 'WechatController@serve');
